#include <stdio.h>
#include <time.h>

#define  SIZE 1024

main(int argc, char **argv)
{
    time_t curtime;
    struct tm *loctime;
    char buffer[SIZE];
    char ulogfile[SIZE];
    char susp_cmd[SIZE];
    char sys_cmd[SIZE];
    char res_cmd[SIZE];
    int ret;

    memset(buffer,   0x00, SIZE);
    memset(ulogfile, 0x00, SIZE);
    memset(susp_cmd, 0x00, SIZE);
    memset(sys_cmd,  0x00, SIZE);
    memset(res_cmd,  0x00, SIZE);

    curtime = time(NULL);
    loctime = localtime(&curtime);
    strftime(buffer, SIZE, "%m%d%y", loctime);

    sprintf(ulogfile, "%s.%s", getenv("ULOGPFX"), buffer);
    sprintf(susp_cmd, "tmadmin << ! \nsusp -i %s \nquit \n!", argv[1]);
    sprintf(sys_cmd, "tail -n 0 -f %s | awk '{ if ($4==\"CONNECTED\" ) exit 1}'", ulogfile);
    sprintf(res_cmd, "tmadmin << ! \nres -i %s \nquit \n!", argv[1]);

    printf("ulogfile: =====> %s\n", ulogfile);
    printf("susp_cmd: =====> %s\n", susp_cmd);
    printf("sys_cmd: =====> %s\n", sys_cmd);
    printf("res_cmd: =====> %s\n", res_cmd);

    return(0);
}
